package com.hb.C_Lambda表达式和集合.高阶函数


/**
        public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {
        for (element in this) if (predicate(element)) destination.add(element)
        return destination
        }

    filter底层调用了filterTo
 */
fun main() {
    //过滤出是偶数的元素
    println((0..5).filter { it % 2 == 0 }) // 输出 [1, 3, 5]
}